﻿using PHMEE.ToolKits;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PHMEE
{
    /// <summary>
    /// 异步电动机
    /// </summary>
    public class AsynElectricMotor : Equipment
    {
        protected AsynElectricMotor()
        {

        }

        public AsynElectricMotor(Guid id, Guid unitId, string name, string nameen, int number)
            : base(id, unitId, name, nameen, number)
        {

        }

        /// <summary>
        /// 功率
        /// </summary>
        [NotMapped]
        public double Power { get; set; }

        /// <summary>
        /// 额定电压
        /// </summary>
        [NotMapped]
        public double RatedVoltage { get; set; }

        /// <summary>
        /// 额定电流
        /// </summary>
        [NotMapped]
        public double RatedCurrent { get; set; }

        /// <summary>
        /// 频率
        /// </summary>
        [NotMapped]
        public double Frequency { get; set; }

        /// <summary>
        /// 电机转速
        /// </summary>
        [NotMapped]
        public double MotorSpeed { get; set; }

        /// <summary>
        /// 绝缘等级
        /// </summary>
        [NotMapped]
        public string InsulationLevel { get; set; }

        /// <summary>
        /// 转子条数
        /// </summary>
        [NotMapped]
        public double RotorBarsNumber { get; set; }

        /// <summary>
        /// 基座类型
        /// </summary>
        [NotMapped]
        public ConnectMode ConnectMode { get; set; }

        /// <summary>
        /// 转动方式
        /// </summary>
        [NotMapped]
        public RotationMode RotationMode { get; set; }

        /// <summary>
        /// 电机驱动端轴承型号1
        /// </summary>
        [NotMapped]
        public string DriveEndBearModelFirst { get; set; }

        /// <summary>
        /// 电机驱动端轴承厂商1
        /// </summary>
        [NotMapped]
        public int DriveEndBearFactoryFirst { get; set; }

        /// <summary>
        /// 电机驱动端轴承型号2
        /// </summary>
        [NotMapped]
        public string DriveEndBearModelSecond { get; set; }

        /// <summary>
        /// 电机驱动端轴承厂商2
        /// </summary>
        [NotMapped]
        public int DriveEndBearFactorySecond { get; set; }

        /// <summary>
        /// 电机自由端轴承型号
        /// </summary>
        [NotMapped]
        public string NonDriveEndBearModel { get; set; }

        /// <summary>
        /// 电机自由端轴承厂商
        /// </summary>
        [NotMapped]
        public int NonDriveEndBearFactory { get; set; }

        public override void SerializeProperties(Dictionary<string, object> derivedPropertiesJson)
        {
            var properties = PHMEECoreHelper.GetDerivedProperties(this);
            this.DerivedPropertiesJson = derivedPropertiesJson.Where(item => properties.Keys.Any(p => string.Equals(p, item.Key, StringComparison.OrdinalIgnoreCase))).ToDictionary();
        }

        public override void DeserializeProperties()
        {
            PHMEECoreHelper.SetDerivedProperties(this, DerivedPropertiesJson);
        }
    }
}
